﻿jzcode.event = {
    _eventDict: [],
    sendEvent: function (name, dataString) {
        if ("undefined" != typeof CZScene) {
            CZScene.netEventSend(name, dataString);
        } else {
            this.callback(name, dataString);
            //for (var index = 0; index < this._eventDict.length; index++) {
            //    if (this._eventDict[index].name == name) {
            //        this._eventDict[index].callback(name, dataString);
            //        return;
            //    }
            //}
        }
    },
    registerEvent: function (name, callback) {
        for (var index = 0; index < this._eventDict.length; index++) {
            if (this._eventDict[index].name == name) {
                return;
            }
        }
        this._eventDict.push({ name: name, callback: callback });
    },
    callback: function (name, dataString) {
        for (var index = 0; index < this._eventDict.length; index++) {
            if (this._eventDict[index].name == name) {
                this._eventDict[index].callback(name, dataString);
                return;
            }
        }
    }
}